package com.ymatou.userservice.testcase;

import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.userservice.parameter.CheckThirdPartyUserIsRealNeedBindMobileDtoBean;
import com.ymatou.userservice.service.CheckThirdPartyUserIsRealNeedBindMobileDtoCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.UserCallService;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.constant.ECode;
import com.ymttest.utils.constant.ThirdPartyType;
/**
*是否绑定手机
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_CheckThirdPartyUserIsRealNeedBindMobileDto{
	private static CheckThirdPartyUserIsRealNeedBindMobileDtoBean checkthirdpartyuserisrealneedbindmobiledtoBean;
	private static CheckThirdPartyUserIsRealNeedBindMobileDtoCall checkthirdpartyuserisrealneedbindmobiledtoCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("是否绑定手机");
	}

	@Before
	public void caseUp() {
		checkthirdpartyuserisrealneedbindmobiledtoBean=new CheckThirdPartyUserIsRealNeedBindMobileDtoBean();
		checkthirdpartyuserisrealneedbindmobiledtoCall=new CheckThirdPartyUserIsRealNeedBindMobileDtoCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(checkthirdpartyuserisrealneedbindmobiledtoCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CheckThirdPartyUserIsRealNeedBindMobileDto_001() {
		Logger.start(true,"ali绑定手机查询Result:no,成功");
		try {
			String phone = TestDataManager.getPhoneNum();
			String aliUser = "ali_"+TestDataManager.getRandomNum(10);
			UserCallService.regByAli(aliUser, phone, true, "注册成功");
			Thread.sleep(3000);
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyId(aliUser);
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyType(ThirdPartyType.ALI);
			checkthirdpartyuserisrealneedbindmobiledtoCall.setData(checkthirdpartyuserisrealneedbindmobiledtoBean);
			checkthirdpartyuserisrealneedbindmobiledtoCall.callService();
			Logger.verifyEquals(ECode.SUCCESS, checkthirdpartyuserisrealneedbindmobiledtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("no", checkthirdpartyuserisrealneedbindmobiledtoCall.getString("Result"), "验证Code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CheckThirdPartyUserIsRealNeedBindMobileDto_002() {
		Logger.start(true,"ali不绑定手机查询Result:yes,成功");
		try {
			String aliUser = "ali_"+TestDataManager.getRandomNum(10);
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyId(aliUser);
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyType(ThirdPartyType.ALI);
			checkthirdpartyuserisrealneedbindmobiledtoCall.setData(checkthirdpartyuserisrealneedbindmobiledtoBean);
			checkthirdpartyuserisrealneedbindmobiledtoCall.callService();			
			Logger.verifyEquals(ECode.ERROR400, checkthirdpartyuserisrealneedbindmobiledtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("yes", checkthirdpartyuserisrealneedbindmobiledtoCall.getString("Result"), "验证Code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_CheckThirdPartyUserIsRealNeedBindMobileDto_003() {
		Logger.start(true,"不输入ThirdPartyId，失败");
		try {
			String aliUser = "ali_"+TestDataManager.getRandomNum(10);
//			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyId(aliUser);
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyType(ThirdPartyType.ALI);
			checkthirdpartyuserisrealneedbindmobiledtoCall.setData(checkthirdpartyuserisrealneedbindmobiledtoBean);
			checkthirdpartyuserisrealneedbindmobiledtoCall.callService();			
			Logger.verifyEquals("100", checkthirdpartyuserisrealneedbindmobiledtoCall.getString("ResponseCode"), "验证Code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_CheckThirdPartyUserIsRealNeedBindMobileDto_004() {
		Logger.start(true,"不输入ThirdPartyType,失败");
		try {
			String aliUser = "ali_"+TestDataManager.getRandomNum(10);
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyId(aliUser);
//			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyType(ThirdPartyType.ALI);
			checkthirdpartyuserisrealneedbindmobiledtoCall.setData(checkthirdpartyuserisrealneedbindmobiledtoBean);
			checkthirdpartyuserisrealneedbindmobiledtoCall.callService();			
			Logger.verifyEquals("100", checkthirdpartyuserisrealneedbindmobiledtoCall.getString("ResponseCode"), "验证Code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	@Ignore
	//暂不考虑
	public void Tc_CheckThirdPartyUserIsRealNeedBindMobileDto_005() {
		Logger.start(true,"输入错误ThirdPartyType,失败");
		try {
			String aliUser = "ali_"+TestDataManager.getRandomNum(10);
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyId(aliUser);
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyType(ThirdPartyType.ALI+1);
			checkthirdpartyuserisrealneedbindmobiledtoCall.setData(checkthirdpartyuserisrealneedbindmobiledtoBean);
			checkthirdpartyuserisrealneedbindmobiledtoCall.callService();			
			Logger.verifyEquals(ECode.ERROR500, checkthirdpartyuserisrealneedbindmobiledtoCall.getString("ResponseCode"), "验证Code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CheckThirdPartyUserIsRealNeedBindMobileDto_006() {
		Logger.start(true,"weixin绑定手机查询Result:no,成功");
		try {
			String phone = TestDataManager.getPhoneNum();
			String aliUser = "wx_"+TestDataManager.getRandomNum(10);
			UserCallService.regByWeiXin(aliUser, phone, true, "注册成功");
			Thread.sleep(3000);
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyId(aliUser);
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyType(ThirdPartyType.WEIXIN);
			checkthirdpartyuserisrealneedbindmobiledtoCall.setData(checkthirdpartyuserisrealneedbindmobiledtoBean);
			checkthirdpartyuserisrealneedbindmobiledtoCall.callService();
			Logger.verifyEquals(ECode.SUCCESS, checkthirdpartyuserisrealneedbindmobiledtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("no", checkthirdpartyuserisrealneedbindmobiledtoCall.getString("Result"), "验证Code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CheckThirdPartyUserIsRealNeedBindMobileDto_007() {
		Logger.start(true,"weixin不绑定手机查询Result:yes,成功");
		try {
			String aliUser = "wx_"+TestDataManager.getRandomNum(10);
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyId(aliUser);
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyType(ThirdPartyType.WEIXIN);
			checkthirdpartyuserisrealneedbindmobiledtoCall.setData(checkthirdpartyuserisrealneedbindmobiledtoBean);
			checkthirdpartyuserisrealneedbindmobiledtoCall.callService();			
			Logger.verifyEquals(ECode.ERROR400, checkthirdpartyuserisrealneedbindmobiledtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("yes", checkthirdpartyuserisrealneedbindmobiledtoCall.getString("Result"), "验证Code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CheckThirdPartyUserIsRealNeedBindMobileDto_008() {
		Logger.start(true,"weibo绑定手机查询Result:no,成功");
		try {
			String phone = TestDataManager.getPhoneNum();
			String aliUser = "weibo_"+TestDataManager.getRandomNum(10);
			UserCallService.regByWeibo(aliUser, phone, true, "注册成功");
			Thread.sleep(3000);
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyId(aliUser);
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyType(ThirdPartyType.WEIBO);
			checkthirdpartyuserisrealneedbindmobiledtoCall.setData(checkthirdpartyuserisrealneedbindmobiledtoBean);
			checkthirdpartyuserisrealneedbindmobiledtoCall.callService();
			Logger.verifyEquals(ECode.SUCCESS, checkthirdpartyuserisrealneedbindmobiledtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("no", checkthirdpartyuserisrealneedbindmobiledtoCall.getString("Result"), "验证Code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CheckThirdPartyUserIsRealNeedBindMobileDto_009() {
		Logger.start(true,"weibo不绑定手机查询Result:yes,成功");
		try {
			String aliUser = "wb_"+TestDataManager.getRandomNum(10);
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyId(aliUser);
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyType(ThirdPartyType.ALI);
			checkthirdpartyuserisrealneedbindmobiledtoCall.setData(checkthirdpartyuserisrealneedbindmobiledtoBean);
			checkthirdpartyuserisrealneedbindmobiledtoCall.callService();			
			Logger.verifyEquals(ECode.ERROR400, checkthirdpartyuserisrealneedbindmobiledtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("yes", checkthirdpartyuserisrealneedbindmobiledtoCall.getString("Result"), "验证Code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
//	@Test
//	@Category({P1.class})
//	@TestCase
//	public void Tc_CheckThirdPartyUserIsRealNeedBindMobileDto_010() {
//		Logger.start(true,"ali绑定手机查询Result:no,成功");
//		try {
//			//这个存量数据待确认
//			//select top 1* from Ymt_User_At_Wexin_Identify left join Ymt_MobilePhoneAccount on Ymt_User_At_Wexin_Identify.iYmtUserId=Ymt_MobilePhoneAccount.iUserId where Ymt_User_At_Wexin_Identify.IsBind=1 and Ymt_MobilePhoneAccount.sAccountName is null
//			String wx ="oA7HCt_RZRUAZzC5-Fw-yTtWH5s4";
//			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyId(wx);
//			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyType(ThirdPartyType.WEIXIN);
//			checkthirdpartyuserisrealneedbindmobiledtoCall.setData(checkthirdpartyuserisrealneedbindmobiledtoBean);
//			checkthirdpartyuserisrealneedbindmobiledtoCall.callService();
//			Logger.verifyEquals(ECode.SUCCESS, checkthirdpartyuserisrealneedbindmobiledtoCall.getString("ResponseCode"), "验证Code");
//			Logger.verifyEquals("no", checkthirdpartyuserisrealneedbindmobiledtoCall.getString("Result"), "验证Code");
//		} catch (Exception e) {
//			Logger.fail(e);
//		}
//	}
}